using UnityEngine;
using System.Collections;

public class Weapon : MonoBehaviour {

	// Projectile stats
	public GameObject projectile;
	public float projectileSpeed = 30;
	public float damage = 20;
	public AudioClip projectileSound;
	
	void Start()
	{
		// we will want to play sounds here	
		
	}
	
	
	void Update () 
	{
		
	}
	
	public void Shoot()
	{
		// if the projectile is not null
		if(projectile)
		{
			// Create a bullet instance at the player's position
			GameObject bullet = (GameObject)Instantiate(projectile, transform.position, transform.rotation);
			
			// Ignore collision with the player's collider
			Physics.IgnoreCollision(bullet.collider, collider);
			
			// Set the move direction for the bullet's rigidbody
			bullet.rigidbody.AddForce(transform.forward * projectileSpeed, ForceMode.VelocityChange);

			// Set the bullet to be deleted 5 seconds after creation
			Destroy(bullet, 5);
		}	
	}
}

